home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / fioben.zip / CAT2.CPP < prev    next >
C/C++ Source or Header  |  1993-02-09  |  2KB  |  78 lines

  1. #include    <windows.h>
  2. #include    <stdio.h>
  3. #include    <iostream.h>
  4. #include    <iomanip.h>
  5. #include    <fstream.h>
  6. #include    <string.h>
  7.  
  8. ofstream    CERR("results.out", ios::app);
  9. int    BUFLEN = 0x10000;
  10.  
  11. ostream    & operator << (ostream & os, SYSTEMTIME & r)
  12. {
  13.     static    const char    * const rgszDayNames[] =
  14.         {
  15.         "Sunday",
  16.         "Monday",
  17.         "Tuesday",
  18.         "Wednesday",
  19.         "Thursday",
  20.         "Friday",
  21.         "Saturday",
  22.         0
  23.         };
  24.     char    chFill = os.fill();
  25.     os.fill('0');
  26.     os //--------------------------------- << rgszDayNames[r.wDayOfWeek] << ' '
  27.         << setw(2) << r.wMonth << '/'
  28.         << setw(2) << r.wDay << '/'
  29.         << setw(2) << r.wYear << ' '
  30.         << setw(2) << r.wHour << ':'
  31.         << setw(2) << r.wMinute << ':'
  32.         //------------------- << setw(2) << r.wSecond
  33.         ;
  34.     os.fill(chFill);
  35.     return    os;
  36. }
  37.  
  38. void cat(FILE *fp)
  39. {
  40.     char    szBuf[8192];
  41.     size_t    nRead;
  42.     while (fgets(szBuf, sizeof(szBuf), fp) )
  43.         {
  44.         if (EOF == fputs(szBuf, stdout) )
  45.             {
  46.             CERR << GetLastError()
  47.                 << ": fputs." << endl;
  48.             }
  49.         }
  50. }
  51.  
  52. int main(int argc, char **argv)
  53. {
  54.     SYSTEMTIME    sNow;
  55.     GetLocalTime(&sNow);
  56.     CERR << sNow << "===> " << GetCommandLine() << endl;
  57.  
  58.     if (argc < 2)
  59.         {
  60.         cat(stdin);
  61.         return    0;
  62.         }
  63.     DWORD    dwStart = GetTickCount();
  64.     for (int iArg = 1; iArg < argc; iArg++)
  65.         {
  66.         FILE *fp = fopen(argv[iArg], "r");
  67.         if (0 == fp)
  68.             continue;
  69.         cat(fp);
  70.         fclose(fp);
  71.         }
  72.     dwStart = GetTickCount( ) - dwStart;
  73.      CERR << "**** Total time: " << (dwStart / 1000)
  74.         << '.' << (dwStart % 1000) << " seconds."
  75.         << endl;
  76.     return    0;
  77. }
  78.